#!/usr/bin/python
import os,sys,re
pkglist=open(sys.argv[1],'r')
for p in pkglist:
	p=p.strip()
	filename=os.path.basename(p)
	varname=re.match(r'^([\w-]+)-[\d\.]+a?\.[\w\.]+$',filename).group(1)
	varname=re.sub('-','_',varname).upper()
	varval=re.match(r'^([\w-]+-[\d\.]+a?)\.[\w\.]+$',filename).group(1)
	if os.getenv('SOURCE_DIR')==None: raise Exception('$SOURCE_DIR not found.')
	if os.path.exists(os.getenv('SOURCE_DIR')+'/'+varval)==False:
		raise Exception('Parse error.', p)
	print '%s=%s'%(varname, varval)
